//
//  ChannelPosts.m
//  __PRODUCTNAME__
//
//  Created by Hanlingyu on 16/09/12
//  Copyright (c) apple. All rights reserved.
//

#import "ChannelPosts.h"
#import "ChannelPostImg.h"
#import "ChannelPostChannel.h"
#import "ChannelVoice.h"
@implementation ChannelPosts

- (void)setValue:(id)value forKey:(NSString *)key {
    [super setValue:value forKey:key];
    if ([key isEqualToString:@"img"]) {
        NSMutableArray *array = [NSMutableArray array];
        for (NSDictionary *dic in value) {
            ChannelPostImg *img = [ChannelPostImg modelWithDic:dic];
            [array addObject:img];
        }
        _img = array;
    } else if ([key isEqualToString:@"channel"]) {
        ChannelPostChannel *postChannel = [ChannelPostChannel modelWithDic:value];
        _channel = postChannel;
    } else if ([key isEqualToString:@"voice"]) {
        ChannelVoice *voice = [ChannelVoice modelWithDic:value];
        _voice = voice;
    }
}

- (void)setValue:(id)value forUndefinedKey:(NSString *)key {
    [super setValue:value forUndefinedKey:key];
    if ([key isEqualToString:@"id"]) {
        _ID = value;
    }
}

+ (NSDictionary *)objectClassInArray{
    return @{@"img" : [ChannelPostImg class]};
}

@end
